<?php
    require_once 'config.php'; 
    require_once 'startup.php'; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />      
    <title>Havhøkerens Nyhedsbrev</title>     
    
    <link rel="icon" href="<?php echo $config["url"]; ?>/img/favicon.png">
    <link type="text/css" rel="stylesheet" href="<?php echo $config["url"]; ?>css/style.css" />
    <link type="text/css" rel="stylesheet" href="<?php echo $config["url"]; ?>css/jquery.simplemodal.css" /> 
    
    <script type="text/javascript" src="<?php echo $config["url"]; ?>scripts/jquery-1.4.2.js"></script>     
    <script type="text/javascript" src="<?php echo $config["url"]; ?>scripts/jquery.simplemodal.js"></script>     
    <script type="text/javascript" src="<?php echo $config["url"]; ?>scripts/simplemodal.formstyle.js"></script>     
    <script type="text/javascript">    
    // <![CDATA[
        var msg = 'Indtast din e-mailadresse her';
        
        jQuery(document).ready(function(){
            jQuery('#unsubscriber').click(function(event){
                event.preventDefault();
                
                var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;                   
                if(jQuery('#email').val() == '' || !mail_filter.test(jQuery('#email').val())){
                    confirm('Nyhedsbreve', 'Indtast venligst en gyldig e-mail adresse.', 'notify'); 
                }
                else{
                    //jQuery('#subscriber_form').submit();
                    jQuery.post(
                        '<?php echo $config['url'] . 'newsletter.php'; ?>',
                        {'email': jQuery('#email').val(), 'method': 'unsubscriber'},
                        function(data){
                            if(data){
                                var arr = jQuery.parseJSON(data);
                                
                                if(arr['type'] == 1){ 
                                    jQuery('#form_msg').hide();
                                    jQuery('#email').hide();
                                    jQuery('#subscriber').hide();
                                    jQuery('#unsubscriber').hide();   
                                    
                                    jQuery('#finish_msg').html(arr['status']); 
                                    jQuery('#finish_msg').show();     
                                }
                                else{
                                    confirm('Nyhedsbreve', arr['status'], 'notify');    
                                }               
                            }
                            //jQuery('#email').val('');                            
                        }                
                    );        
                }  
            });   
                
            jQuery('#subscriber').click(function(even){
                even.preventDefault();    
                
                var mail_filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;                   
                if(jQuery('#email').val() == '' || !mail_filter.test(jQuery('#email').val())){
                    confirm('Nyhedsbreve', 'Indtast venligst en gyldig e-mail adresse.', 'notify');
                }
                else{
                    //jQuery('#subscriber_form').submit();
                    jQuery.post(
                        '<?php echo $config['url'] . 'newsletter.php'; ?>',
                        {'email': jQuery('#email').val(), 'method': 'subscriber'},
                        function(data){
                            if(data){
                                var arr = jQuery.parseJSON(data);
                                
                                if(arr['type'] == 1){
                                    jQuery('#form_msg').hide();
                                    jQuery('#email').hide();
                                    jQuery('#subscriber').hide();
                                    jQuery('#unsubscriber').hide();  
                                    
                                    jQuery('#finish_msg').html('Tak for tilmelding vores nyhedsbrev!<br /><br />' + arr['status']); 
                                    jQuery('#finish_msg').show();
                                }
                                else{
                                    confirm('Nyhedsbreve', arr['status'], 'notify');    
                                }               
                            }
                            //jQuery('#email').val('');
                        }                
                    );        
                }
            });    
            
            jQuery('#email').blur(function(){ 
                if(jQuery(this).val() == ''){                                   
                    jQuery(this).val(msg);    
                }
            });
            jQuery('#email').focus(function(){ 
                if(jQuery(this).val() == msg){
                    jQuery(this).val('');    
                }
            });
        });             
    // ]]> 
    </script>     
</head>
<body>     
    <!-- begin: #Page -->
    <div id="page">
	    <div id="page_bg">	 
            <!-- begin: #Header -->
            <div id="header" class="w900">
                <img class="content" src="img/logo.png" />
                <br class="clear_left" />
            </div>
            <!-- end: #Header -->
            <!-- begin: #Main -->
            <div id="main" class="w900">
                <div class="main_bg">
          	        <div class="main_content">
            	        <img src="img/icon_mail.png" class="float_left" />
                        <div class="float_left w350">
                            <p id="form_msg" class="p10t">Ja tak, jeg vil gerne modtage Havhøkerens Nyhedsbrev</p>
                            <p id="finish_msg" class="p10t" style="display: none;"></p>
                            <form id="subscriber_form" method="post" action="<?php echo $config['url']; ?>"> 
                                <input type="text" id="email" name="email" value="Indtast din e-mailadresse her" class="input_1" /><br />                           
                                
                                <a id="subscriber" href="#"><img src="img/btn_subscribe.png" alt="" /></a>
                                <a id="unsubscriber" href="#"><img src="img/btn_reset.png" alt="" /></a>
                                <a href="http://havhokeren.dk/"><img src="img/btn_goforside.png" alt="" /></a>
                            </form> 
                        </div>
                    </div>
                </div>
              
                <!-- Dialog -->
                <div id='confirm'>
                    <div class='header'><span>Confirm</span></div>
                    <div class='message'></div>                   
                    <div class='buttons'>
                        <div id="button_continue" class='continue'>Fortsæt</div> 
                        <div id="button_no" class='no simplemodal-close'>Ingen</div>
                        <div id="button_yes" class='yes'>Ja</div>                  
                    </div>
                </div>
            </div>
            <!-- end: #Main -->
            <!-- begin: #Footer -->
            <div id="footer">
                <div class="w500">
                    <p align="center">Copyright © <?php echo date('Y'); ?> <a href="http://www.jyskvvs.dk" target="_blank">havhokeren.dk</a>. All rights reserved.</p>
                    <p align="center">Design by <a href="http://mwc.com.vn" target="_blank">My Web Creations</a></p>
                    <br class="clear" />
                </div>
            </div>
            <!-- end: #Footer -->
        </div>
    </div>
    <!-- end: #Page -->
</body>
</html>
